import uuid

from CloudEngine.core.VTActor import VTActor
from Connector.client import res_success
from service.func.topology_get import topology_get


class CmdRenderShow:
    name = "render_show"
    id = uuid.uuid4()

    def __init__(self, service, Params, Tag, Type):
        self.service = service
        self.params = Params
        self.tag = Tag
        self.type = Type

    async def execute(self):
        show_list: list[str] = self.params.get("list", ["2d"])
        ac: VTActor = self.service.get_first_actor()
        line_ac = self.service.get_second_actor()
        d3_ac = self.service.get_third_actor()
        ac.visible_off()
        if line_ac:
            line_ac.visible_off()
        if d3_ac:
            d3_ac.visible_off()
        for show in show_list:
            if show == "2d":
                ac.visible_on()
            elif show == "3d" and d3_ac:
                d3_ac.visible_on()
            elif show == "line" and line_ac:
                line_ac.visible_on()
        self.service.app.reset_camera()
        self.service.app.render()
        await res_success(self.tag, self.type, {"status": "ok"})
